﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.Globalization;

using CNCSoft.EWinform;
using CNCSoft.EWinform.ControlUtils;
using CNCSoft.EWinform.ERPApps;
using CNCSoft.EWinform.AGrid;
using CNCSoft.EData;

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

using System.Threading;
using System.Globalization;

using Common;

namespace CNCSoft.ErpApps.TMS {

	/// <summary>
	/// Summary description for TienMatPhieuChi.
	/// </summary>
    public class TienMatPhieuChi : System.Windows.Forms.Form
    {
		private CNCSoft.EWinform.ValidText txtNgayChungTu;
		private System.Windows.Forms.TextBox txtSoChungTu;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.TextBox txtDienGiai;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.TextBox txtSoTien;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.TextBox txtDiaChi;
		private System.Windows.Forms.Label label10;
        private System.Windows.Forms.TextBox txtChungTuKemTheo;
        private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Label label13;
		private System.Windows.Forms.Label label15;
		private System.Windows.Forms.Label label16;
		internal System.Windows.Forms.Panel pnlButtons;
		internal System.Windows.Forms.Button cmdModify;
		internal System.Windows.Forms.Button cmdCancel;
		internal System.Windows.Forms.Button cmdPrint;
		internal System.Windows.Forms.Button cmdView;
		internal System.Windows.Forms.Button cmdDelete;
		internal System.Windows.Forms.Button cmdAddNew;
		internal System.Windows.Forms.Button cmdUpdate;
		private System.Windows.Forms.Panel pnlBottom;
		private System.Windows.Forms.Label lblStatus;
		private System.Windows.Forms.Panel pnlNevigator;
		internal System.Windows.Forms.Button cmdMoveFirst;
		internal System.Windows.Forms.Button cmdMovePrevious;
		internal System.Windows.Forms.Button cmdMoveNext;
		internal System.Windows.Forms.Button cmdMoveLast;
		private System.Windows.Forms.Label lblRecordInfo;
		private System.Windows.Forms.PictureBox picboxHelp;
		private System.Windows.Forms.PictureBox picboxNote;
		private System.Windows.Forms.TextBox txtHoTenNguoiNhanTien;
        private System.Windows.Forms.ComboBox cboLyDoChi;
		private System.Windows.Forms.TextBox txtMaSoThue;
		private System.Windows.Forms.TextBox txtSerialHoaDon;
		private System.Windows.Forms.Button cmdLookupDVNhanTiep;
		private System.Windows.Forms.DataGrid dgridChiTietPC;
		private System.Windows.Forms.ErrorProvider ep;
		private System.Windows.Forms.Button cmdXemTK;
        private System.Windows.Forms.TextBox txtSoHoaDon;
		private System.Windows.Forms.TextBox txtThueSuat;
		private System.Windows.Forms.CheckBox chkNhapTTT;
		private System.Windows.Forms.GroupBox pnlTTT;
		private System.Windows.Forms.Label lblThueSuat;
        private CNCSoft.EWinform.ValidText txtNgayHoaDon;
        private ToolTip toolTip1;
        private TextBox txtDonViNhanTien;
        private Label lblTenDonViNhanTien;
        private Label label11;
        private CheckBox chkTTHet;
        private txtChonTuDanhMuc txtSoPhieuYeuCau;
        private CheckBox optBaoGomCaHocSinh;
        private IContainer components;

		public TienMatPhieuChi()
		{
			//
			// Required for Windows Form Designer support
			//

            // Sets the UI culture to VietNamese (VietNam) / English
            if (GlobalVariable.WSInfo.Language == "Tiếng Việt")
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("vi-VN");
            else if (GlobalVariable.WSInfo.Language == "English")
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en");

			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TienMatPhieuChi));
            this.txtNgayChungTu = new CNCSoft.EWinform.ValidText();
            this.txtSoChungTu = new System.Windows.Forms.TextBox();
            this.label9 = new System.Windows.Forms.Label();
            this.label8 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.txtDienGiai = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.txtHoTenNguoiNhanTien = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.cboLyDoChi = new System.Windows.Forms.ComboBox();
            this.txtSoTien = new System.Windows.Forms.TextBox();
            this.label6 = new System.Windows.Forms.Label();
            this.txtDiaChi = new System.Windows.Forms.TextBox();
            this.label10 = new System.Windows.Forms.Label();
            this.txtChungTuKemTheo = new System.Windows.Forms.TextBox();
            this.dgridChiTietPC = new System.Windows.Forms.DataGrid();
            this.txtMaSoThue = new System.Windows.Forms.TextBox();
            this.label7 = new System.Windows.Forms.Label();
            this.pnlTTT = new System.Windows.Forms.GroupBox();
            this.txtNgayHoaDon = new CNCSoft.EWinform.ValidText();
            this.label13 = new System.Windows.Forms.Label();
            this.label15 = new System.Windows.Forms.Label();
            this.label16 = new System.Windows.Forms.Label();
            this.txtSoHoaDon = new System.Windows.Forms.TextBox();
            this.txtSerialHoaDon = new System.Windows.Forms.TextBox();
            this.lblThueSuat = new System.Windows.Forms.Label();
            this.txtThueSuat = new System.Windows.Forms.TextBox();
            this.pnlButtons = new System.Windows.Forms.Panel();
            this.cmdModify = new System.Windows.Forms.Button();
            this.cmdCancel = new System.Windows.Forms.Button();
            this.cmdPrint = new System.Windows.Forms.Button();
            this.cmdView = new System.Windows.Forms.Button();
            this.cmdDelete = new System.Windows.Forms.Button();
            this.cmdAddNew = new System.Windows.Forms.Button();
            this.cmdUpdate = new System.Windows.Forms.Button();
            this.pnlBottom = new System.Windows.Forms.Panel();
            this.lblStatus = new System.Windows.Forms.Label();
            this.pnlNevigator = new System.Windows.Forms.Panel();
            this.cmdMoveFirst = new System.Windows.Forms.Button();
            this.cmdMovePrevious = new System.Windows.Forms.Button();
            this.cmdMoveNext = new System.Windows.Forms.Button();
            this.cmdMoveLast = new System.Windows.Forms.Button();
            this.lblRecordInfo = new System.Windows.Forms.Label();
            this.picboxNote = new System.Windows.Forms.PictureBox();
            this.picboxHelp = new System.Windows.Forms.PictureBox();
            this.ep = new System.Windows.Forms.ErrorProvider(this.components);
            this.chkNhapTTT = new System.Windows.Forms.CheckBox();
            this.cmdXemTK = new System.Windows.Forms.Button();
            this.cmdLookupDVNhanTiep = new System.Windows.Forms.Button();
            this.chkTTHet = new System.Windows.Forms.CheckBox();
            this.txtDonViNhanTien = new System.Windows.Forms.TextBox();
            this.lblTenDonViNhanTien = new System.Windows.Forms.Label();
            this.label11 = new System.Windows.Forms.Label();
            this.optBaoGomCaHocSinh = new System.Windows.Forms.CheckBox();
            this.txtSoPhieuYeuCau = new CNCSoft.ErpApps.TMS.txtChonTuDanhMuc();
            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
            ((System.ComponentModel.ISupportInitialize)(this.dgridChiTietPC)).BeginInit();
            this.pnlTTT.SuspendLayout();
            this.pnlButtons.SuspendLayout();
            this.pnlBottom.SuspendLayout();
            this.pnlNevigator.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.picboxNote)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.picboxHelp)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.ep)).BeginInit();
            this.SuspendLayout();
            // 
            // txtNgayChungTu
            // 
            resources.ApplyResources(this.txtNgayChungTu, "txtNgayChungTu");
            this.txtNgayChungTu.ClearTime = false;
            this.txtNgayChungTu.DateDelimiter = "/";
            this.txtNgayChungTu.DateInputFormat = CNCSoft.EUtilities.DateFormat.DDMMYYYY;
            this.txtNgayChungTu.DateOutputFormat = CNCSoft.EUtilities.DateFormat.DDMMYYYY;
            this.ep.SetError(this.txtNgayChungTu, resources.GetString("txtNgayChungTu.Error"));
            this.txtNgayChungTu.FieldReference = null;
            this.ep.SetIconAlignment(this.txtNgayChungTu, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtNgayChungTu.IconAlignment"))));
            this.ep.SetIconPadding(this.txtNgayChungTu, ((int)(resources.GetObject("txtNgayChungTu.IconPadding"))));
            this.txtNgayChungTu.MaskEdit = "";
            this.txtNgayChungTu.MessageLanguage = CNCSoft.EWinform.ValidText.MessageLanguages.Vietnamese;
            this.txtNgayChungTu.Name = "txtNgayChungTu";
            this.txtNgayChungTu.RegExPattern = CNCSoft.EWinform.ValidText.RegularExpressionModes.AutomatedDate;
            this.txtNgayChungTu.Required = false;
            this.txtNgayChungTu.ShowErrorIcon = true;
            this.toolTip1.SetToolTip(this.txtNgayChungTu, resources.GetString("txtNgayChungTu.ToolTip"));
            this.txtNgayChungTu.ValidationMode = CNCSoft.EWinform.ValidText.ValidationModes.None;
            this.txtNgayChungTu.ValidText = "0123456789/ ";
            this.txtNgayChungTu.YearPrefix = ((short)(20));
            // 
            // txtSoChungTu
            // 
            resources.ApplyResources(this.txtSoChungTu, "txtSoChungTu");
            this.ep.SetError(this.txtSoChungTu, resources.GetString("txtSoChungTu.Error"));
            this.txtSoChungTu.ForeColor = System.Drawing.Color.ForestGreen;
            this.ep.SetIconAlignment(this.txtSoChungTu, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtSoChungTu.IconAlignment"))));
            this.ep.SetIconPadding(this.txtSoChungTu, ((int)(resources.GetObject("txtSoChungTu.IconPadding"))));
            this.txtSoChungTu.Name = "txtSoChungTu";
            this.toolTip1.SetToolTip(this.txtSoChungTu, resources.GetString("txtSoChungTu.ToolTip"));
            // 
            // label9
            // 
            resources.ApplyResources(this.label9, "label9");
            this.ep.SetError(this.label9, resources.GetString("label9.Error"));
            this.ep.SetIconAlignment(this.label9, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label9.IconAlignment"))));
            this.ep.SetIconPadding(this.label9, ((int)(resources.GetObject("label9.IconPadding"))));
            this.label9.Name = "label9";
            this.toolTip1.SetToolTip(this.label9, resources.GetString("label9.ToolTip"));
            // 
            // label8
            // 
            resources.ApplyResources(this.label8, "label8");
            this.ep.SetError(this.label8, resources.GetString("label8.Error"));
            this.ep.SetIconAlignment(this.label8, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label8.IconAlignment"))));
            this.ep.SetIconPadding(this.label8, ((int)(resources.GetObject("label8.IconPadding"))));
            this.label8.Name = "label8";
            this.toolTip1.SetToolTip(this.label8, resources.GetString("label8.ToolTip"));
            // 
            // label5
            // 
            resources.ApplyResources(this.label5, "label5");
            this.ep.SetError(this.label5, resources.GetString("label5.Error"));
            this.ep.SetIconAlignment(this.label5, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label5.IconAlignment"))));
            this.ep.SetIconPadding(this.label5, ((int)(resources.GetObject("label5.IconPadding"))));
            this.label5.Name = "label5";
            this.toolTip1.SetToolTip(this.label5, resources.GetString("label5.ToolTip"));
            // 
            // txtDienGiai
            // 
            resources.ApplyResources(this.txtDienGiai, "txtDienGiai");
            this.ep.SetError(this.txtDienGiai, resources.GetString("txtDienGiai.Error"));
            this.ep.SetIconAlignment(this.txtDienGiai, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtDienGiai.IconAlignment"))));
            this.ep.SetIconPadding(this.txtDienGiai, ((int)(resources.GetObject("txtDienGiai.IconPadding"))));
            this.txtDienGiai.Name = "txtDienGiai";
            this.txtDienGiai.Tag = "<LyDoThu> cho <TenDonVi>";
            this.toolTip1.SetToolTip(this.txtDienGiai, resources.GetString("txtDienGiai.ToolTip"));
            this.txtDienGiai.Validated += new System.EventHandler(this.txtDienGiai_Validated);
            // 
            // label3
            // 
            resources.ApplyResources(this.label3, "label3");
            this.ep.SetError(this.label3, resources.GetString("label3.Error"));
            this.ep.SetIconAlignment(this.label3, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label3.IconAlignment"))));
            this.ep.SetIconPadding(this.label3, ((int)(resources.GetObject("label3.IconPadding"))));
            this.label3.Name = "label3";
            this.toolTip1.SetToolTip(this.label3, resources.GetString("label3.ToolTip"));
            // 
            // txtHoTenNguoiNhanTien
            // 
            resources.ApplyResources(this.txtHoTenNguoiNhanTien, "txtHoTenNguoiNhanTien");
            this.ep.SetError(this.txtHoTenNguoiNhanTien, resources.GetString("txtHoTenNguoiNhanTien.Error"));
            this.ep.SetIconAlignment(this.txtHoTenNguoiNhanTien, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtHoTenNguoiNhanTien.IconAlignment"))));
            this.ep.SetIconPadding(this.txtHoTenNguoiNhanTien, ((int)(resources.GetObject("txtHoTenNguoiNhanTien.IconPadding"))));
            this.txtHoTenNguoiNhanTien.Name = "txtHoTenNguoiNhanTien";
            this.toolTip1.SetToolTip(this.txtHoTenNguoiNhanTien, resources.GetString("txtHoTenNguoiNhanTien.ToolTip"));
            // 
            // label2
            // 
            resources.ApplyResources(this.label2, "label2");
            this.ep.SetError(this.label2, resources.GetString("label2.Error"));
            this.ep.SetIconAlignment(this.label2, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label2.IconAlignment"))));
            this.ep.SetIconPadding(this.label2, ((int)(resources.GetObject("label2.IconPadding"))));
            this.label2.Name = "label2";
            this.toolTip1.SetToolTip(this.label2, resources.GetString("label2.ToolTip"));
            // 
            // label1
            // 
            resources.ApplyResources(this.label1, "label1");
            this.ep.SetError(this.label1, resources.GetString("label1.Error"));
            this.ep.SetIconAlignment(this.label1, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label1.IconAlignment"))));
            this.ep.SetIconPadding(this.label1, ((int)(resources.GetObject("label1.IconPadding"))));
            this.label1.Name = "label1";
            this.toolTip1.SetToolTip(this.label1, resources.GetString("label1.ToolTip"));
            // 
            // label4
            // 
            resources.ApplyResources(this.label4, "label4");
            this.ep.SetError(this.label4, resources.GetString("label4.Error"));
            this.ep.SetIconAlignment(this.label4, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label4.IconAlignment"))));
            this.ep.SetIconPadding(this.label4, ((int)(resources.GetObject("label4.IconPadding"))));
            this.label4.Name = "label4";
            this.toolTip1.SetToolTip(this.label4, resources.GetString("label4.ToolTip"));
            // 
            // cboLyDoChi
            // 
            resources.ApplyResources(this.cboLyDoChi, "cboLyDoChi");
            this.ep.SetError(this.cboLyDoChi, resources.GetString("cboLyDoChi.Error"));
            this.ep.SetIconAlignment(this.cboLyDoChi, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cboLyDoChi.IconAlignment"))));
            this.ep.SetIconPadding(this.cboLyDoChi, ((int)(resources.GetObject("cboLyDoChi.IconPadding"))));
            this.cboLyDoChi.Name = "cboLyDoChi";
            this.toolTip1.SetToolTip(this.cboLyDoChi, resources.GetString("cboLyDoChi.ToolTip"));
            this.cboLyDoChi.SelectedIndexChanged += new System.EventHandler(this.cboLyDoThu_SelectedIndexChanged);
            // 
            // txtSoTien
            // 
            resources.ApplyResources(this.txtSoTien, "txtSoTien");
            this.txtSoTien.BackColor = System.Drawing.Color.PaleGoldenrod;
            this.ep.SetError(this.txtSoTien, resources.GetString("txtSoTien.Error"));
            this.txtSoTien.ForeColor = System.Drawing.Color.IndianRed;
            this.ep.SetIconAlignment(this.txtSoTien, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtSoTien.IconAlignment"))));
            this.ep.SetIconPadding(this.txtSoTien, ((int)(resources.GetObject("txtSoTien.IconPadding"))));
            this.txtSoTien.Name = "txtSoTien";
            this.toolTip1.SetToolTip(this.txtSoTien, resources.GetString("txtSoTien.ToolTip"));
            this.txtSoTien.TextChanged += new System.EventHandler(this.txtSoTien_TextChanged_1);
            this.txtSoTien.Validated += new System.EventHandler(this.txtSoTien_Validated);
            // 
            // label6
            // 
            resources.ApplyResources(this.label6, "label6");
            this.ep.SetError(this.label6, resources.GetString("label6.Error"));
            this.ep.SetIconAlignment(this.label6, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label6.IconAlignment"))));
            this.ep.SetIconPadding(this.label6, ((int)(resources.GetObject("label6.IconPadding"))));
            this.label6.Name = "label6";
            this.toolTip1.SetToolTip(this.label6, resources.GetString("label6.ToolTip"));
            // 
            // txtDiaChi
            // 
            resources.ApplyResources(this.txtDiaChi, "txtDiaChi");
            this.ep.SetError(this.txtDiaChi, resources.GetString("txtDiaChi.Error"));
            this.ep.SetIconAlignment(this.txtDiaChi, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtDiaChi.IconAlignment"))));
            this.ep.SetIconPadding(this.txtDiaChi, ((int)(resources.GetObject("txtDiaChi.IconPadding"))));
            this.txtDiaChi.Name = "txtDiaChi";
            this.toolTip1.SetToolTip(this.txtDiaChi, resources.GetString("txtDiaChi.ToolTip"));
            // 
            // label10
            // 
            resources.ApplyResources(this.label10, "label10");
            this.ep.SetError(this.label10, resources.GetString("label10.Error"));
            this.ep.SetIconAlignment(this.label10, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label10.IconAlignment"))));
            this.ep.SetIconPadding(this.label10, ((int)(resources.GetObject("label10.IconPadding"))));
            this.label10.Name = "label10";
            this.toolTip1.SetToolTip(this.label10, resources.GetString("label10.ToolTip"));
            // 
            // txtChungTuKemTheo
            // 
            resources.ApplyResources(this.txtChungTuKemTheo, "txtChungTuKemTheo");
            this.ep.SetError(this.txtChungTuKemTheo, resources.GetString("txtChungTuKemTheo.Error"));
            this.ep.SetIconAlignment(this.txtChungTuKemTheo, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtChungTuKemTheo.IconAlignment"))));
            this.ep.SetIconPadding(this.txtChungTuKemTheo, ((int)(resources.GetObject("txtChungTuKemTheo.IconPadding"))));
            this.txtChungTuKemTheo.Name = "txtChungTuKemTheo";
            this.toolTip1.SetToolTip(this.txtChungTuKemTheo, resources.GetString("txtChungTuKemTheo.ToolTip"));
            // 
            // dgridChiTietPC
            // 
            resources.ApplyResources(this.dgridChiTietPC, "dgridChiTietPC");
            this.dgridChiTietPC.CaptionVisible = false;
            this.dgridChiTietPC.DataMember = "";
            this.ep.SetError(this.dgridChiTietPC, resources.GetString("dgridChiTietPC.Error"));
            this.dgridChiTietPC.HeaderForeColor = System.Drawing.SystemColors.ControlText;
            this.ep.SetIconAlignment(this.dgridChiTietPC, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("dgridChiTietPC.IconAlignment"))));
            this.ep.SetIconPadding(this.dgridChiTietPC, ((int)(resources.GetObject("dgridChiTietPC.IconPadding"))));
            this.dgridChiTietPC.Name = "dgridChiTietPC";
            this.toolTip1.SetToolTip(this.dgridChiTietPC, resources.GetString("dgridChiTietPC.ToolTip"));
            this.dgridChiTietPC.Validated += new System.EventHandler(this.dgridChiTietPC_Validated);
            // 
            // txtMaSoThue
            // 
            resources.ApplyResources(this.txtMaSoThue, "txtMaSoThue");
            this.ep.SetError(this.txtMaSoThue, resources.GetString("txtMaSoThue.Error"));
            this.ep.SetIconAlignment(this.txtMaSoThue, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtMaSoThue.IconAlignment"))));
            this.ep.SetIconPadding(this.txtMaSoThue, ((int)(resources.GetObject("txtMaSoThue.IconPadding"))));
            this.txtMaSoThue.Name = "txtMaSoThue";
            this.toolTip1.SetToolTip(this.txtMaSoThue, resources.GetString("txtMaSoThue.ToolTip"));
            // 
            // label7
            // 
            resources.ApplyResources(this.label7, "label7");
            this.ep.SetError(this.label7, resources.GetString("label7.Error"));
            this.ep.SetIconAlignment(this.label7, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label7.IconAlignment"))));
            this.ep.SetIconPadding(this.label7, ((int)(resources.GetObject("label7.IconPadding"))));
            this.label7.Name = "label7";
            this.toolTip1.SetToolTip(this.label7, resources.GetString("label7.ToolTip"));
            // 
            // pnlTTT
            // 
            resources.ApplyResources(this.pnlTTT, "pnlTTT");
            this.pnlTTT.Controls.Add(this.txtNgayHoaDon);
            this.pnlTTT.Controls.Add(this.label13);
            this.pnlTTT.Controls.Add(this.label15);
            this.pnlTTT.Controls.Add(this.label16);
            this.pnlTTT.Controls.Add(this.txtSoHoaDon);
            this.pnlTTT.Controls.Add(this.txtSerialHoaDon);
            this.ep.SetError(this.pnlTTT, resources.GetString("pnlTTT.Error"));
            this.ep.SetIconAlignment(this.pnlTTT, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("pnlTTT.IconAlignment"))));
            this.ep.SetIconPadding(this.pnlTTT, ((int)(resources.GetObject("pnlTTT.IconPadding"))));
            this.pnlTTT.Name = "pnlTTT";
            this.pnlTTT.TabStop = false;
            this.toolTip1.SetToolTip(this.pnlTTT, resources.GetString("pnlTTT.ToolTip"));
            // 
            // txtNgayHoaDon
            // 
            resources.ApplyResources(this.txtNgayHoaDon, "txtNgayHoaDon");
            this.txtNgayHoaDon.ClearTime = false;
            this.txtNgayHoaDon.DateDelimiter = "/";
            this.txtNgayHoaDon.DateInputFormat = CNCSoft.EUtilities.DateFormat.DDMMYYYY;
            this.txtNgayHoaDon.DateOutputFormat = CNCSoft.EUtilities.DateFormat.DDMMYYYY;
            this.ep.SetError(this.txtNgayHoaDon, resources.GetString("txtNgayHoaDon.Error"));
            this.txtNgayHoaDon.FieldReference = null;
            this.ep.SetIconAlignment(this.txtNgayHoaDon, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtNgayHoaDon.IconAlignment"))));
            this.ep.SetIconPadding(this.txtNgayHoaDon, ((int)(resources.GetObject("txtNgayHoaDon.IconPadding"))));
            this.txtNgayHoaDon.MaskEdit = "";
            this.txtNgayHoaDon.MessageLanguage = CNCSoft.EWinform.ValidText.MessageLanguages.Vietnamese;
            this.txtNgayHoaDon.Name = "txtNgayHoaDon";
            this.txtNgayHoaDon.RegExPattern = CNCSoft.EWinform.ValidText.RegularExpressionModes.AutomatedDate;
            this.txtNgayHoaDon.Required = false;
            this.txtNgayHoaDon.ShowErrorIcon = false;
            this.toolTip1.SetToolTip(this.txtNgayHoaDon, resources.GetString("txtNgayHoaDon.ToolTip"));
            this.txtNgayHoaDon.ValidationMode = CNCSoft.EWinform.ValidText.ValidationModes.None;
            this.txtNgayHoaDon.ValidText = null;
            this.txtNgayHoaDon.YearPrefix = ((short)(20));
            // 
            // label13
            // 
            resources.ApplyResources(this.label13, "label13");
            this.ep.SetError(this.label13, resources.GetString("label13.Error"));
            this.ep.SetIconAlignment(this.label13, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label13.IconAlignment"))));
            this.ep.SetIconPadding(this.label13, ((int)(resources.GetObject("label13.IconPadding"))));
            this.label13.Name = "label13";
            this.toolTip1.SetToolTip(this.label13, resources.GetString("label13.ToolTip"));
            // 
            // label15
            // 
            resources.ApplyResources(this.label15, "label15");
            this.ep.SetError(this.label15, resources.GetString("label15.Error"));
            this.ep.SetIconAlignment(this.label15, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label15.IconAlignment"))));
            this.ep.SetIconPadding(this.label15, ((int)(resources.GetObject("label15.IconPadding"))));
            this.label15.Name = "label15";
            this.toolTip1.SetToolTip(this.label15, resources.GetString("label15.ToolTip"));
            // 
            // label16
            // 
            resources.ApplyResources(this.label16, "label16");
            this.ep.SetError(this.label16, resources.GetString("label16.Error"));
            this.ep.SetIconAlignment(this.label16, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label16.IconAlignment"))));
            this.ep.SetIconPadding(this.label16, ((int)(resources.GetObject("label16.IconPadding"))));
            this.label16.Name = "label16";
            this.toolTip1.SetToolTip(this.label16, resources.GetString("label16.ToolTip"));
            // 
            // txtSoHoaDon
            // 
            resources.ApplyResources(this.txtSoHoaDon, "txtSoHoaDon");
            this.ep.SetError(this.txtSoHoaDon, resources.GetString("txtSoHoaDon.Error"));
            this.ep.SetIconAlignment(this.txtSoHoaDon, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtSoHoaDon.IconAlignment"))));
            this.ep.SetIconPadding(this.txtSoHoaDon, ((int)(resources.GetObject("txtSoHoaDon.IconPadding"))));
            this.txtSoHoaDon.Name = "txtSoHoaDon";
            this.toolTip1.SetToolTip(this.txtSoHoaDon, resources.GetString("txtSoHoaDon.ToolTip"));
            // 
            // txtSerialHoaDon
            // 
            resources.ApplyResources(this.txtSerialHoaDon, "txtSerialHoaDon");
            this.ep.SetError(this.txtSerialHoaDon, resources.GetString("txtSerialHoaDon.Error"));
            this.ep.SetIconAlignment(this.txtSerialHoaDon, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtSerialHoaDon.IconAlignment"))));
            this.ep.SetIconPadding(this.txtSerialHoaDon, ((int)(resources.GetObject("txtSerialHoaDon.IconPadding"))));
            this.txtSerialHoaDon.Name = "txtSerialHoaDon";
            this.toolTip1.SetToolTip(this.txtSerialHoaDon, resources.GetString("txtSerialHoaDon.ToolTip"));
            // 
            // lblThueSuat
            // 
            resources.ApplyResources(this.lblThueSuat, "lblThueSuat");
            this.ep.SetError(this.lblThueSuat, resources.GetString("lblThueSuat.Error"));
            this.ep.SetIconAlignment(this.lblThueSuat, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("lblThueSuat.IconAlignment"))));
            this.ep.SetIconPadding(this.lblThueSuat, ((int)(resources.GetObject("lblThueSuat.IconPadding"))));
            this.lblThueSuat.Name = "lblThueSuat";
            this.toolTip1.SetToolTip(this.lblThueSuat, resources.GetString("lblThueSuat.ToolTip"));
            // 
            // txtThueSuat
            // 
            resources.ApplyResources(this.txtThueSuat, "txtThueSuat");
            this.txtThueSuat.BackColor = System.Drawing.Color.PaleGoldenrod;
            this.ep.SetError(this.txtThueSuat, resources.GetString("txtThueSuat.Error"));
            this.txtThueSuat.ForeColor = System.Drawing.Color.IndianRed;
            this.ep.SetIconAlignment(this.txtThueSuat, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtThueSuat.IconAlignment"))));
            this.ep.SetIconPadding(this.txtThueSuat, ((int)(resources.GetObject("txtThueSuat.IconPadding"))));
            this.txtThueSuat.Name = "txtThueSuat";
            this.toolTip1.SetToolTip(this.txtThueSuat, resources.GetString("txtThueSuat.ToolTip"));
            this.txtThueSuat.Validated += new System.EventHandler(this.txtThueSuat_Validated);
            // 
            // pnlButtons
            // 
            resources.ApplyResources(this.pnlButtons, "pnlButtons");
            this.pnlButtons.Controls.Add(this.cmdModify);
            this.pnlButtons.Controls.Add(this.cmdCancel);
            this.pnlButtons.Controls.Add(this.cmdPrint);
            this.pnlButtons.Controls.Add(this.cmdView);
            this.pnlButtons.Controls.Add(this.cmdDelete);
            this.pnlButtons.Controls.Add(this.cmdAddNew);
            this.pnlButtons.Controls.Add(this.cmdUpdate);
            this.ep.SetError(this.pnlButtons, resources.GetString("pnlButtons.Error"));
            this.ep.SetIconAlignment(this.pnlButtons, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("pnlButtons.IconAlignment"))));
            this.ep.SetIconPadding(this.pnlButtons, ((int)(resources.GetObject("pnlButtons.IconPadding"))));
            this.pnlButtons.Name = "pnlButtons";
            this.toolTip1.SetToolTip(this.pnlButtons, resources.GetString("pnlButtons.ToolTip"));
            // 
            // cmdModify
            // 
            resources.ApplyResources(this.cmdModify, "cmdModify");
            this.cmdModify.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdModify, resources.GetString("cmdModify.Error"));
            this.cmdModify.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdModify, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdModify.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdModify, ((int)(resources.GetObject("cmdModify.IconPadding"))));
            this.cmdModify.Name = "cmdModify";
            this.toolTip1.SetToolTip(this.cmdModify, resources.GetString("cmdModify.ToolTip"));
            this.cmdModify.Click += new System.EventHandler(this.cmdModify_Click);
            // 
            // cmdCancel
            // 
            resources.ApplyResources(this.cmdCancel, "cmdCancel");
            this.cmdCancel.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdCancel, resources.GetString("cmdCancel.Error"));
            this.cmdCancel.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdCancel, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdCancel.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdCancel, ((int)(resources.GetObject("cmdCancel.IconPadding"))));
            this.cmdCancel.Name = "cmdCancel";
            this.toolTip1.SetToolTip(this.cmdCancel, resources.GetString("cmdCancel.ToolTip"));
            this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
            // 
            // cmdPrint
            // 
            resources.ApplyResources(this.cmdPrint, "cmdPrint");
            this.cmdPrint.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdPrint, resources.GetString("cmdPrint.Error"));
            this.cmdPrint.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdPrint, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdPrint.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdPrint, ((int)(resources.GetObject("cmdPrint.IconPadding"))));
            this.cmdPrint.Name = "cmdPrint";
            this.toolTip1.SetToolTip(this.cmdPrint, resources.GetString("cmdPrint.ToolTip"));
            this.cmdPrint.Click += new System.EventHandler(this.cmdPrint_Click);
            // 
            // cmdView
            // 
            resources.ApplyResources(this.cmdView, "cmdView");
            this.cmdView.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdView, resources.GetString("cmdView.Error"));
            this.cmdView.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdView, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdView.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdView, ((int)(resources.GetObject("cmdView.IconPadding"))));
            this.cmdView.Name = "cmdView";
            this.toolTip1.SetToolTip(this.cmdView, resources.GetString("cmdView.ToolTip"));
            this.cmdView.Click += new System.EventHandler(this.cmdView_Click);
            // 
            // cmdDelete
            // 
            resources.ApplyResources(this.cmdDelete, "cmdDelete");
            this.cmdDelete.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdDelete, resources.GetString("cmdDelete.Error"));
            this.cmdDelete.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdDelete, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdDelete.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdDelete, ((int)(resources.GetObject("cmdDelete.IconPadding"))));
            this.cmdDelete.Name = "cmdDelete";
            this.toolTip1.SetToolTip(this.cmdDelete, resources.GetString("cmdDelete.ToolTip"));
            this.cmdDelete.Click += new System.EventHandler(this.cmdDelete_Click);
            // 
            // cmdAddNew
            // 
            resources.ApplyResources(this.cmdAddNew, "cmdAddNew");
            this.cmdAddNew.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdAddNew, resources.GetString("cmdAddNew.Error"));
            this.cmdAddNew.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdAddNew, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdAddNew.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdAddNew, ((int)(resources.GetObject("cmdAddNew.IconPadding"))));
            this.cmdAddNew.Name = "cmdAddNew";
            this.toolTip1.SetToolTip(this.cmdAddNew, resources.GetString("cmdAddNew.ToolTip"));
            this.cmdAddNew.Click += new System.EventHandler(this.cmdAddNew_Click);
            // 
            // cmdUpdate
            // 
            resources.ApplyResources(this.cmdUpdate, "cmdUpdate");
            this.cmdUpdate.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdUpdate, resources.GetString("cmdUpdate.Error"));
            this.cmdUpdate.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdUpdate, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdUpdate.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdUpdate, ((int)(resources.GetObject("cmdUpdate.IconPadding"))));
            this.cmdUpdate.Name = "cmdUpdate";
            this.toolTip1.SetToolTip(this.cmdUpdate, resources.GetString("cmdUpdate.ToolTip"));
            this.cmdUpdate.Click += new System.EventHandler(this.cmdUpdate_Click);
            // 
            // pnlBottom
            // 
            resources.ApplyResources(this.pnlBottom, "pnlBottom");
            this.pnlBottom.Controls.Add(this.lblStatus);
            this.pnlBottom.Controls.Add(this.pnlNevigator);
            this.pnlBottom.Controls.Add(this.picboxNote);
            this.pnlBottom.Controls.Add(this.picboxHelp);
            this.ep.SetError(this.pnlBottom, resources.GetString("pnlBottom.Error"));
            this.ep.SetIconAlignment(this.pnlBottom, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("pnlBottom.IconAlignment"))));
            this.ep.SetIconPadding(this.pnlBottom, ((int)(resources.GetObject("pnlBottom.IconPadding"))));
            this.pnlBottom.Name = "pnlBottom";
            this.toolTip1.SetToolTip(this.pnlBottom, resources.GetString("pnlBottom.ToolTip"));
            // 
            // lblStatus
            // 
            resources.ApplyResources(this.lblStatus, "lblStatus");
            this.ep.SetError(this.lblStatus, resources.GetString("lblStatus.Error"));
            this.ep.SetIconAlignment(this.lblStatus, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("lblStatus.IconAlignment"))));
            this.ep.SetIconPadding(this.lblStatus, ((int)(resources.GetObject("lblStatus.IconPadding"))));
            this.lblStatus.Name = "lblStatus";
            this.toolTip1.SetToolTip(this.lblStatus, resources.GetString("lblStatus.ToolTip"));
            // 
            // pnlNevigator
            // 
            resources.ApplyResources(this.pnlNevigator, "pnlNevigator");
            this.pnlNevigator.Controls.Add(this.cmdMoveFirst);
            this.pnlNevigator.Controls.Add(this.cmdMovePrevious);
            this.pnlNevigator.Controls.Add(this.cmdMoveNext);
            this.pnlNevigator.Controls.Add(this.cmdMoveLast);
            this.pnlNevigator.Controls.Add(this.lblRecordInfo);
            this.ep.SetError(this.pnlNevigator, resources.GetString("pnlNevigator.Error"));
            this.ep.SetIconAlignment(this.pnlNevigator, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("pnlNevigator.IconAlignment"))));
            this.ep.SetIconPadding(this.pnlNevigator, ((int)(resources.GetObject("pnlNevigator.IconPadding"))));
            this.pnlNevigator.Name = "pnlNevigator";
            this.toolTip1.SetToolTip(this.pnlNevigator, resources.GetString("pnlNevigator.ToolTip"));
            // 
            // cmdMoveFirst
            // 
            resources.ApplyResources(this.cmdMoveFirst, "cmdMoveFirst");
            this.cmdMoveFirst.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdMoveFirst, resources.GetString("cmdMoveFirst.Error"));
            this.cmdMoveFirst.ForeColor = System.Drawing.Color.Maroon;
            this.ep.SetIconAlignment(this.cmdMoveFirst, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdMoveFirst.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdMoveFirst, ((int)(resources.GetObject("cmdMoveFirst.IconPadding"))));
            this.cmdMoveFirst.Name = "cmdMoveFirst";
            this.toolTip1.SetToolTip(this.cmdMoveFirst, resources.GetString("cmdMoveFirst.ToolTip"));
            this.cmdMoveFirst.Click += new System.EventHandler(this.cmdMoveFirst_Click);
            // 
            // cmdMovePrevious
            // 
            resources.ApplyResources(this.cmdMovePrevious, "cmdMovePrevious");
            this.cmdMovePrevious.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdMovePrevious, resources.GetString("cmdMovePrevious.Error"));
            this.cmdMovePrevious.ForeColor = System.Drawing.Color.Maroon;
            this.ep.SetIconAlignment(this.cmdMovePrevious, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdMovePrevious.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdMovePrevious, ((int)(resources.GetObject("cmdMovePrevious.IconPadding"))));
            this.cmdMovePrevious.Name = "cmdMovePrevious";
            this.toolTip1.SetToolTip(this.cmdMovePrevious, resources.GetString("cmdMovePrevious.ToolTip"));
            this.cmdMovePrevious.Click += new System.EventHandler(this.cmdMovePrevious_Click);
            // 
            // cmdMoveNext
            // 
            resources.ApplyResources(this.cmdMoveNext, "cmdMoveNext");
            this.cmdMoveNext.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdMoveNext, resources.GetString("cmdMoveNext.Error"));
            this.cmdMoveNext.ForeColor = System.Drawing.Color.Maroon;
            this.ep.SetIconAlignment(this.cmdMoveNext, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdMoveNext.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdMoveNext, ((int)(resources.GetObject("cmdMoveNext.IconPadding"))));
            this.cmdMoveNext.Name = "cmdMoveNext";
            this.toolTip1.SetToolTip(this.cmdMoveNext, resources.GetString("cmdMoveNext.ToolTip"));
            this.cmdMoveNext.Click += new System.EventHandler(this.cmdMoveNext_Click);
            // 
            // cmdMoveLast
            // 
            resources.ApplyResources(this.cmdMoveLast, "cmdMoveLast");
            this.cmdMoveLast.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdMoveLast, resources.GetString("cmdMoveLast.Error"));
            this.cmdMoveLast.ForeColor = System.Drawing.Color.Maroon;
            this.ep.SetIconAlignment(this.cmdMoveLast, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdMoveLast.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdMoveLast, ((int)(resources.GetObject("cmdMoveLast.IconPadding"))));
            this.cmdMoveLast.Name = "cmdMoveLast";
            this.toolTip1.SetToolTip(this.cmdMoveLast, resources.GetString("cmdMoveLast.ToolTip"));
            this.cmdMoveLast.Click += new System.EventHandler(this.cmdMoveLast_Click);
            // 
            // lblRecordInfo
            // 
            resources.ApplyResources(this.lblRecordInfo, "lblRecordInfo");
            this.lblRecordInfo.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.ep.SetError(this.lblRecordInfo, resources.GetString("lblRecordInfo.Error"));
            this.ep.SetIconAlignment(this.lblRecordInfo, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("lblRecordInfo.IconAlignment"))));
            this.ep.SetIconPadding(this.lblRecordInfo, ((int)(resources.GetObject("lblRecordInfo.IconPadding"))));
            this.lblRecordInfo.Name = "lblRecordInfo";
            this.toolTip1.SetToolTip(this.lblRecordInfo, resources.GetString("lblRecordInfo.ToolTip"));
            // 
            // picboxNote
            // 
            resources.ApplyResources(this.picboxNote, "picboxNote");
            this.picboxNote.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.picboxNote, resources.GetString("picboxNote.Error"));
            this.ep.SetIconAlignment(this.picboxNote, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("picboxNote.IconAlignment"))));
            this.ep.SetIconPadding(this.picboxNote, ((int)(resources.GetObject("picboxNote.IconPadding"))));
            this.picboxNote.Name = "picboxNote";
            this.picboxNote.TabStop = false;
            this.toolTip1.SetToolTip(this.picboxNote, resources.GetString("picboxNote.ToolTip"));
            this.picboxNote.Click += new System.EventHandler(this.picboxNote_Click);
            // 
            // picboxHelp
            // 
            resources.ApplyResources(this.picboxHelp, "picboxHelp");
            this.picboxHelp.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.picboxHelp, resources.GetString("picboxHelp.Error"));
            this.ep.SetIconAlignment(this.picboxHelp, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("picboxHelp.IconAlignment"))));
            this.ep.SetIconPadding(this.picboxHelp, ((int)(resources.GetObject("picboxHelp.IconPadding"))));
            this.picboxHelp.Name = "picboxHelp";
            this.picboxHelp.TabStop = false;
            this.toolTip1.SetToolTip(this.picboxHelp, resources.GetString("picboxHelp.ToolTip"));
            this.picboxHelp.Click += new System.EventHandler(this.picboxHelp_Click);
            // 
            // ep
            // 
            this.ep.ContainerControl = this;
            resources.ApplyResources(this.ep, "ep");
            // 
            // chkNhapTTT
            // 
            resources.ApplyResources(this.chkNhapTTT, "chkNhapTTT");
            this.chkNhapTTT.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.chkNhapTTT, resources.GetString("chkNhapTTT.Error"));
            this.ep.SetIconAlignment(this.chkNhapTTT, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("chkNhapTTT.IconAlignment"))));
            this.ep.SetIconPadding(this.chkNhapTTT, ((int)(resources.GetObject("chkNhapTTT.IconPadding"))));
            this.chkNhapTTT.Name = "chkNhapTTT";
            this.toolTip1.SetToolTip(this.chkNhapTTT, resources.GetString("chkNhapTTT.ToolTip"));
            this.chkNhapTTT.CheckedChanged += new System.EventHandler(this.chkNhapTTT_CheckedChanged);
            // 
            // cmdXemTK
            // 
            resources.ApplyResources(this.cmdXemTK, "cmdXemTK");
            this.cmdXemTK.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdXemTK, resources.GetString("cmdXemTK.Error"));
            this.cmdXemTK.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdXemTK, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdXemTK.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdXemTK, ((int)(resources.GetObject("cmdXemTK.IconPadding"))));
            this.cmdXemTK.Name = "cmdXemTK";
            this.cmdXemTK.TabStop = false;
            this.toolTip1.SetToolTip(this.cmdXemTK, resources.GetString("cmdXemTK.ToolTip"));
            this.cmdXemTK.Click += new System.EventHandler(this.cmdXemTK_Click);
            // 
            // cmdLookupDVNhanTiep
            // 
            resources.ApplyResources(this.cmdLookupDVNhanTiep, "cmdLookupDVNhanTiep");
            this.cmdLookupDVNhanTiep.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.cmdLookupDVNhanTiep, resources.GetString("cmdLookupDVNhanTiep.Error"));
            this.cmdLookupDVNhanTiep.ForeColor = System.Drawing.Color.DodgerBlue;
            this.ep.SetIconAlignment(this.cmdLookupDVNhanTiep, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("cmdLookupDVNhanTiep.IconAlignment"))));
            this.ep.SetIconPadding(this.cmdLookupDVNhanTiep, ((int)(resources.GetObject("cmdLookupDVNhanTiep.IconPadding"))));
            this.cmdLookupDVNhanTiep.Name = "cmdLookupDVNhanTiep";
            this.cmdLookupDVNhanTiep.TabStop = false;
            this.toolTip1.SetToolTip(this.cmdLookupDVNhanTiep, resources.GetString("cmdLookupDVNhanTiep.ToolTip"));
            this.cmdLookupDVNhanTiep.Click += new System.EventHandler(this.cmdLookupDVNhanTiep_Click);
            // 
            // chkTTHet
            // 
            resources.ApplyResources(this.chkTTHet, "chkTTHet");
            this.chkTTHet.Cursor = System.Windows.Forms.Cursors.Hand;
            this.ep.SetError(this.chkTTHet, resources.GetString("chkTTHet.Error"));
            this.ep.SetIconAlignment(this.chkTTHet, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("chkTTHet.IconAlignment"))));
            this.ep.SetIconPadding(this.chkTTHet, ((int)(resources.GetObject("chkTTHet.IconPadding"))));
            this.chkTTHet.Name = "chkTTHet";
            this.toolTip1.SetToolTip(this.chkTTHet, resources.GetString("chkTTHet.ToolTip"));
            // 
            // txtDonViNhanTien
            // 
            resources.ApplyResources(this.txtDonViNhanTien, "txtDonViNhanTien");
            this.ep.SetError(this.txtDonViNhanTien, resources.GetString("txtDonViNhanTien.Error"));
            this.ep.SetIconAlignment(this.txtDonViNhanTien, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtDonViNhanTien.IconAlignment"))));
            this.ep.SetIconPadding(this.txtDonViNhanTien, ((int)(resources.GetObject("txtDonViNhanTien.IconPadding"))));
            this.txtDonViNhanTien.Name = "txtDonViNhanTien";
            this.toolTip1.SetToolTip(this.txtDonViNhanTien, resources.GetString("txtDonViNhanTien.ToolTip"));
            this.txtDonViNhanTien.TextChanged += new System.EventHandler(this.txtDonViNhanTien_TextChanged);
            this.txtDonViNhanTien.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtDonViNhanTien_KeyDown);
            this.txtDonViNhanTien.Validated += new System.EventHandler(this.txtDonViNhanTien_Validated);
            // 
            // lblTenDonViNhanTien
            // 
            resources.ApplyResources(this.lblTenDonViNhanTien, "lblTenDonViNhanTien");
            this.ep.SetError(this.lblTenDonViNhanTien, resources.GetString("lblTenDonViNhanTien.Error"));
            this.ep.SetIconAlignment(this.lblTenDonViNhanTien, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("lblTenDonViNhanTien.IconAlignment"))));
            this.ep.SetIconPadding(this.lblTenDonViNhanTien, ((int)(resources.GetObject("lblTenDonViNhanTien.IconPadding"))));
            this.lblTenDonViNhanTien.Name = "lblTenDonViNhanTien";
            this.toolTip1.SetToolTip(this.lblTenDonViNhanTien, resources.GetString("lblTenDonViNhanTien.ToolTip"));
            // 
            // label11
            // 
            resources.ApplyResources(this.label11, "label11");
            this.ep.SetError(this.label11, resources.GetString("label11.Error"));
            this.ep.SetIconAlignment(this.label11, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("label11.IconAlignment"))));
            this.ep.SetIconPadding(this.label11, ((int)(resources.GetObject("label11.IconPadding"))));
            this.label11.Name = "label11";
            this.toolTip1.SetToolTip(this.label11, resources.GetString("label11.ToolTip"));
            // 
            // optBaoGomCaHocSinh
            // 
            resources.ApplyResources(this.optBaoGomCaHocSinh, "optBaoGomCaHocSinh");
            this.ep.SetError(this.optBaoGomCaHocSinh, resources.GetString("optBaoGomCaHocSinh.Error"));
            this.ep.SetIconAlignment(this.optBaoGomCaHocSinh, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("optBaoGomCaHocSinh.IconAlignment"))));
            this.ep.SetIconPadding(this.optBaoGomCaHocSinh, ((int)(resources.GetObject("optBaoGomCaHocSinh.IconPadding"))));
            this.optBaoGomCaHocSinh.Name = "optBaoGomCaHocSinh";
            this.toolTip1.SetToolTip(this.optBaoGomCaHocSinh, resources.GetString("optBaoGomCaHocSinh.ToolTip"));
            this.optBaoGomCaHocSinh.UseVisualStyleBackColor = true;
            // 
            // txtSoPhieuYeuCau
            // 
            resources.ApplyResources(this.txtSoPhieuYeuCau, "txtSoPhieuYeuCau");
            this.ep.SetError(this.txtSoPhieuYeuCau, resources.GetString("txtSoPhieuYeuCau.Error"));
            this.ep.SetIconAlignment(this.txtSoPhieuYeuCau, ((System.Windows.Forms.ErrorIconAlignment)(resources.GetObject("txtSoPhieuYeuCau.IconAlignment"))));
            this.ep.SetIconPadding(this.txtSoPhieuYeuCau, ((int)(resources.GetObject("txtSoPhieuYeuCau.IconPadding"))));
            this.txtSoPhieuYeuCau.Name = "txtSoPhieuYeuCau";
            this.txtSoPhieuYeuCau.RefField = "SoPYC";
            this.txtSoPhieuYeuCau.RefTable = "View_PhieuYC_CanChi";
            this.toolTip1.SetToolTip(this.txtSoPhieuYeuCau, resources.GetString("txtSoPhieuYeuCau.ToolTip"));
            // 
            // TienMatPhieuChi
            // 
            resources.ApplyResources(this, "$this");
            this.BackColor = System.Drawing.Color.WhiteSmoke;
            this.Controls.Add(this.optBaoGomCaHocSinh);
            this.Controls.Add(this.txtSoPhieuYeuCau);
            this.Controls.Add(this.chkTTHet);
            this.Controls.Add(this.label11);
            this.Controls.Add(this.lblTenDonViNhanTien);
            this.Controls.Add(this.cmdLookupDVNhanTiep);
            this.Controls.Add(this.txtDonViNhanTien);
            this.Controls.Add(this.txtDiaChi);
            this.Controls.Add(this.chkNhapTTT);
            this.Controls.Add(this.cmdXemTK);
            this.Controls.Add(this.pnlButtons);
            this.Controls.Add(this.pnlBottom);
            this.Controls.Add(this.pnlTTT);
            this.Controls.Add(this.txtMaSoThue);
            this.Controls.Add(this.label7);
            this.Controls.Add(this.txtSoTien);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.label10);
            this.Controls.Add(this.txtChungTuKemTheo);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.txtDienGiai);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.txtHoTenNguoiNhanTien);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.txtNgayChungTu);
            this.Controls.Add(this.txtSoChungTu);
            this.Controls.Add(this.label9);
            this.Controls.Add(this.label8);
            this.Controls.Add(this.dgridChiTietPC);
            this.Controls.Add(this.cboLyDoChi);
            this.Controls.Add(this.txtThueSuat);
            this.Controls.Add(this.lblThueSuat);
            this.KeyPreview = true;
            this.Name = "TienMatPhieuChi";
            this.toolTip1.SetToolTip(this, resources.GetString("$this.ToolTip"));
            this.Load += new System.EventHandler(this.TienMatPhieuThu_Load);
            this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TienMatPhieuChi_KeyDown);
            ((System.ComponentModel.ISupportInitialize)(this.dgridChiTietPC)).EndInit();
            this.pnlTTT.ResumeLayout(false);
            this.pnlTTT.PerformLayout();
            this.pnlButtons.ResumeLayout(false);
            this.pnlBottom.ResumeLayout(false);
            this.pnlNevigator.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.picboxNote)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.picboxHelp)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.ep)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

		}
		#endregion

		private void picboxNote_Click(object sender, System.EventArgs e) {
			SimpleObjectNote son = new SimpleObjectNote(GlobalVariable.WSInfo.ConnectionString,
				this.Text, GlobalVariable.WSInfo.UserID);
			son.ShowDialog(this);
		}

		#region [ Variables ]
		    bool cancelHandlers;
		    TienMatPhieuChiData pc;
		    BindingManagerBase bmb;

             //Cac bien phan quyen tren form
            bool DuocQuyenThem = true;
            bool DuocQuyenSua = true;
            bool DuocQuyenXoa = true;
		#endregion

		private void TienMatPhieuThu_Load(object sender, System.EventArgs e) {
			cancelHandlers = true;
			try {
				pc = new TienMatPhieuChiData();

				intiDatabinding();

				pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).ColumnChanged +=new DataColumnChangeEventHandler(TienMatPhieuThu_ColumnChanged);
				pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).RowDeleted +=new DataRowChangeEventHandler(TienMatPhieuThu_RowDeleted);
				
				bmb = this.BindingContext[pc.getDataSet(), "TienMatPC"];

				bmb.PositionChanged +=new EventHandler(bmb_PositionChanged);

			} catch (Exception ex) {
				sendStatus(ex.Message, true);

				MessageBox.Show(this, RS.ERROR_LOAD_FORM, RS.ERROR_LOAD_FORM_CAPTION, 
					MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
				return;
			} finally {
				cancelHandlers = false;
			}
			
            PublicFunction.PhanQuyenForm(this.Name, GlobalVariable.WSInfo.UserID, out DuocQuyenThem, out DuocQuyenSua, out DuocQuyenXoa);

            if (DuocQuyenThem)
                cmdAddNew_Click(cmdAddNew, e);
            else
            {
                setEditMode(false);
                sendStatus("Bạn không có quyền thêm mới", false);
            }

		}

		private void bmb_PositionChanged(object sender, System.EventArgs e) {
			if (cancelHandlers) return;

			cancelHandlers = true;
			if (bmb.Count == 0) {
				this.lblRecordInfo.Text = "0/0";
			} else {
				this.lblRecordInfo.Text = (bmb.Position +1) +"/" +bmb.Count;
			}

			if (bmb.Position >= 0) {
				buildDgridTS();
			}
			cancelHandlers = false;
			//if (cmdAddNew.Enabled && bmb.Position >= 0) {
			//	chkNhapTTT_CheckedChanged(chkNhapTTT, e);
			//	showCoThue();
			//}
            
            try
            {
                lblTenDonViNhanTien.Text = SQLHelper.ExecuteScalar(GlobalVariable.WSInfo.ConnectionString, "SELECT TenDoiTac FROM DM_DOITAC WHERE MaDoiTac= '" + txtDonViNhanTien.Text + "'").ToString();
            }
            catch { }

		}

		private void TienMatPhieuThu_RowDeleted(object sender, DataRowChangeEventArgs e) {
			if (cancelHandlers) return;
			cancelHandlers = true;
			if (pc.getTable(TienMatPhieuChiData.TL.TienMatPC).Rows[bmb.Position].GetChildRows("M_D").Length > 0) {
				this["TongTien"] = pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).Compute("Sum(SoTien)", "SoChungTu='" +this["SoChungTu"] +"'");
			} else {
				this["TongTien"] = 0;
			}
			bmb.EndCurrentEdit();
			cancelHandlers = false;
		}
		
        
        private void TienMatPhieuThu_ColumnChanged(object sender, DataColumnChangeEventArgs e) {
			if (cancelHandlers) return;
			cancelHandlers = true;

            try
            {
                if (e.Column.ColumnName.ToUpper() == "SOTIEN")
                {

                    double sumSoTien = 0;
                    sumSoTien = (double)(decimal)pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).Compute("Sum(SoTien)", "SoChungTu='" + this["SoChungTu"] + "'");
                    txtSoTien.Text = sumSoTien.ToString("N");
                    bmb.EndCurrentEdit();
                }
            }
            catch { }
            finally
            {
                cancelHandlers = false;
            }
		}

		#region [ Commond Methods ]

		private void intiDatabinding() {
			this.txtSoChungTu.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.SoChungTu");
			this.txtNgayChungTu.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.NgayChungTu");
			this.txtNgayChungTu.ActiveDisplayFormat();
            this.txtDonViNhanTien.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.MaDoiTac");
            this.txtHoTenNguoiNhanTien.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.Hoten");
            this.txtDiaChi.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.DiaChi");
            this.txtChungTuKemTheo.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.SoChungtuKemTheo");
            this.txtSoPhieuYeuCau.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.SoPhieuYeuCau");
            this.chkTTHet.DataBindings.Add("Checked", pc.getDataSet(), "TienMatPC.ThanhToanHetPYC");
			this.txtDienGiai.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.DienGiai");
			
			this.txtMaSoThue.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.MaSoThue");
			this.chkNhapTTT.DataBindings.Add("Checked", pc.getDataSet(), "TienMatPC.CoThue");
            this.txtThueSuat.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.ThueSuat");
            this.txtThueSuat.DataBindings["Text"].Parse += new ConvertEventHandler(TienMatPhieuThu_Parse);
            this.txtThueSuat.DataBindings["Text"].Format += new ConvertEventHandler(TienMatPhieuThu_Format);
            this.txtSoHoaDon.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.SoHoaDon");
            this.txtSerialHoaDon.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.SerialHoaDon");
            this.txtNgayHoaDon.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.NgayHoaDon");
            this.txtNgayHoaDon.ActiveDisplayFormat();

			this.cboLyDoChi.DataBindings.Add("SelectedValue", pc.getDataSet(), "TienMatPC.LyDoThuChi");
			this.cboLyDoChi.DataSource = pc.getTable(TienMatPhieuChiData.TL.LyDoChi);
			this.cboLyDoChi.DisplayMember = "DienGiai";
			this.cboLyDoChi.ValueMember = "MaTaiKhoan";

            //Cac kieu tien
            this.txtSoTien.DataBindings.Add("Text", pc.getDataSet(), "TienMatPC.TongTien");
            this.txtSoTien.DataBindings["Text"].Parse += new ConvertEventHandler(TienMatPhieuThu_Parse);
            this.txtSoTien.DataBindings["Text"].Format += new ConvertEventHandler(TienMatPhieuThu_Format);

			dgridChiTietPC.SetDataBinding(pc.getDataSet(), "TienMatPC.M_D");
		}

		private void TienMatPhieuThu_Parse(object sender, ConvertEventArgs e) {
			try {
				if (e.Value == null || (string)e.Value == string.Empty) {
					e.Value = DBNull.Value;
				} else {
					e.Value = double.Parse((string)e.Value);
				}
			} catch {
				sendStatus("Bạn vui lòng nhập đúng định dạng số.", true);
			}
		}

		private void TienMatPhieuThu_Format(object sender, ConvertEventArgs e) {
			try {
				if (Convert.IsDBNull(e.Value)) {
					e.Value = "";
				} else {
					e.Value = ((decimal)e.Value).ToString("N");
				}
			} catch (Exception ex) {
				//sendStatus("Unexpected Error: " +ex.Message, true);
			}
		}

		DataGridAutoResizeSupporter dgridARS = new DataGridAutoResizeSupporter();
		DataGridStyleFactory dgridSF = new DataGridStyleFactory();
		private bool coThue;
		private void buildDgridTS() {

			// Build based on LyDoThu column
			if (cboLyDoChi.SelectedIndex == -1) {
				sendStatus("Bạn vui lòng chọn Lý do chi.");
				return;
			}
			DataRow dr = pc.getTable(TienMatPhieuChiData.TL.LyDoChi).Rows[cboLyDoChi.SelectedIndex];
			
			DataGridTableStyle ts = new DataGridTableStyle();
			ts.MappingName = pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).TableName;

			AGridTextBoxColumn agridTC;

			//			agridTC = new AGridTextBoxColumn();
			//			agridTC.MappingName = "TaiKhoanCo";
			//			agridTC.HeaderText = "Tài khoản có";
			//			agridTC.NullText = "";
			//			agridTC.Width = 100;
			//			agridTC.ReadOnly = true;
			//			ts.GridColumnStyles.Add(agridTC);

			AGridMCComBoBoxColumn colLDT = new AGridMCComBoBoxColumn(pc.getTable(TienMatPhieuChiData.TL.LyDoChi_Detail));
			colLDT.MappingName = "TaiKhoanNo";
			colLDT.HeaderText = "Tài khoản nợ";
			colLDT.DisplayMember = "MaTaiKhoan";
			colLDT.ValueMember = "MaTaiKhoan";
			colLDT.NullText = "";
			colLDT.Width = 100;
			ts.GridColumnStyles.Add(colLDT);

            //Them cot Tieu khoan NO1 = Madoitac
            agridTC = new AGridTextBoxColumn();
            agridTC.MappingName = "MaTieukhoanNO1";
            agridTC.HeaderText = "Tiểu khoản";
            agridTC.NullText = "";
            agridTC.Width = 100;
            ts.GridColumnStyles.Add(agridTC);

			agridTC = new AGridTextBoxColumn();
			agridTC.MappingName = "SoTien";
			agridTC.HeaderText = "Số tiền";
			agridTC.NullText = "";
			agridTC.Width = 100;
			agridTC.Format = "N";
			ts.GridColumnStyles.Add(agridTC);

/*          
			// Build other data column if defined in DM_NGHIEPVU_TAIKHOAN_CHITIET table

			DataTable tblTemp = new DataTable("tblTem");
			SQLHelper.Fill(
				tblTemp, GlobalVariable.WSInfo.ConnectionString,
				"Select * from DM_NGHIEPVU_TAIKHOAN_CHITIET where MaNghiepVu = '" +
				GlobalVariable.WSInfo["TienMat.PhieuChi.MaLoaiCT", "PC"] +"' and MaTaiKhoan = '" +dr["MaTaiKhoan"] +"'");

			for (int index = 0; index < tblTemp.Rows.Count; index++) {
				if (!Convert.IsDBNull(tblTemp.Rows[index]["SQLSoLieu"])) {
					DataTable colData = new DataTable((string)tblTemp.Rows[index]["TenFieldBinding"]);
					SQLHelper.Fill(colData, GlobalVariable.WSInfo.ConnectionString, (string)tblTemp.Rows[index]["SQLSoLieu"]);
					AGridMCComBoBoxColumn col = new AGridMCComBoBoxColumn(colData);
					col.MappingName = (string)tblTemp.Rows[index]["TenFieldBinding"];
					col.HeaderText =(string) tblTemp.Rows[index]["TenCot"];
					col.DisplayMember = (string)tblTemp.Rows[index]["DisplayMember"];
					col.ValueMember = (string)tblTemp.Rows[index]["ValueMember"];
					col.NullText = "";
					col.Width = 100;
					ts.GridColumnStyles.Add(col);
				} else {
//					agridTC = new AGridTextBoxColumn();
//					agridTC.MappingName = (string)tblTemp.Rows[index]["TenFieldBinding"];
//					agridTC.HeaderText =(string) tblTemp.Rows[index]["TenCot"];
//					agridTC.NullText = "";
//					agridTC.Width = 100;
//					ts.GridColumnStyles.Add(agridTC);

					createColumn(ts, tblTemp.Rows[index]);
				}
			}
*/

			agridTC = new AGridTextBoxColumn();
			agridTC.MappingName = "DienGiaiChiTiet";
			agridTC.HeaderText = "Diễn giải chi tiết";
			agridTC.NullText = "";
			agridTC.Width = 300;
			agridTC.Format = "N";
			ts.GridColumnStyles.Add(agridTC);

			dgridChiTietPC.TableStyles.Clear();
			dgridChiTietPC.TableStyles.Add(ts);
			dgridSF.applyStyle(dgridChiTietPC, DataGridStyleFactory.Styles.SexyStyle);
			dgridChiTietPC.TableStyles[0].AllowSorting = false;
		}

		public void createColumn(DataGridTableStyle ts, DataRow drDefine) {

			if (Convert.IsDBNull(drDefine["DataType"]) || drDefine["DataType"].ToString() == string.Empty) {
				AGridTextBoxColumn agridTC = new AGridTextBoxColumn();
				agridTC.MappingName = (string)drDefine["TenFieldBinding"];
				agridTC.HeaderText =(string) drDefine["TenCot"];
				agridTC.NullText = "";
				agridTC.Width = 100;
				ts.GridColumnStyles.Add(agridTC);
			} else {
				switch (drDefine["DataType"].ToString().ToLower()) {
					case "d":
						AGridDateTimeColumn agridDC = new AGridDateTimeColumn();
						agridDC.MappingName = (string)drDefine["TenFieldBinding"];
						agridDC.HeaderText =(string) drDefine["TenCot"];
						agridDC.NullText = "";
						agridDC.DateTimePicker.CustomFormat = "dd/MM/yyyy";
						agridDC.DateTimePicker.Format = DateTimePickerFormat.Short;
						//agridDC.DateTimePicker.DataBindings["af"].
						agridDC.Width = 100;
						ts.GridColumnStyles.Add(agridDC);
						break;
					case "n":
						AGridTextBoxColumn agridTC_n = new AGridTextBoxColumn();
						agridTC_n.MappingName = (string)drDefine["TenFieldBinding"];
						agridTC_n.HeaderText =(string)drDefine["TenCot"];
						agridTC_n.NullText = "";
						agridTC_n.Width = 100;
						agridTC_n.Format = "N";
						ts.GridColumnStyles.Add(agridTC_n);
						break;
					case "c":
						AGridTextBoxColumn agridTC_c = new AGridTextBoxColumn();
						agridTC_c.MappingName = (string)drDefine["TenFieldBinding"];
						agridTC_c.HeaderText =(string)drDefine["TenCot"];
						agridTC_c.NullText = "";
						agridTC_c.Width = 100;
						ts.GridColumnStyles.Add(agridTC_c);
						break;
				}
			}
		}

		private void setEditMode(bool edit) {

			cmdAddNew.Enabled = !edit  && DuocQuyenThem;
			cmdDelete.Enabled = !edit && bmb.Position >= 0 && DuocQuyenXoa;
			cmdModify.Enabled = !edit && bmb.Position >= 0  && DuocQuyenSua;
			cmdPrint.Enabled = !edit && bmb.Position >= 0;
			cmdView.Enabled = !edit;
			cmdUpdate.Enabled = edit;
			cmdCancel.Enabled = edit;

			cmdLookupDVNhanTiep.Enabled = edit;

			cmdMoveFirst.Enabled = !edit;
			cmdMovePrevious.Enabled = !edit;
			cmdMoveNext.Enabled = !edit;
			cmdMoveLast.Enabled = !edit;

			txtSoChungTu.ReadOnly = true;
			txtNgayChungTu.ReadOnly = !edit;
			txtSoTien.ReadOnly = !edit;
			txtDiaChi.ReadOnly = !edit;
			txtDienGiai.ReadOnly = !edit;
			txtChungTuKemTheo.ReadOnly = !edit;
			txtHoTenNguoiNhanTien.ReadOnly = !edit;
			txtDonViNhanTien.Enabled = edit;
			cboLyDoChi.Enabled = edit;
			txtMaSoThue.ReadOnly = !edit;
            txtSoTien.Enabled = edit; 

			chkNhapTTT.Enabled = edit;
			if (edit && !chkNhapTTT.Checked) {
				txtThueSuat.Visible = false;
				lblThueSuat.Visible = false;
			}

			dgridChiTietPC.ReadOnly = !edit;
			cmdXemTK.Enabled = bmb.Position >= 0;
		}

		#endregion

		#region [ Command Events ]

		private void cmdAddNew_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (pc.createNewRow()) {
				bmb.Position = bmb.Count -1;
				setEditMode(true);
				txtDonViNhanTien.Focus();
			}
			cancelHandlers= false;
			bmb_PositionChanged(bmb, e);
			sendStatus("Đang trong trạng thái thêm mới...", false);
			chkNhapTTT.Checked = false;
		}

		private void cmdUpdate_Click(object sender, System.EventArgs e) {
			if (txtDonViNhanTien.Text == "") {
				ep.SetError(txtDonViNhanTien, "Bạn vui lòng chọn đơn vị nộp tiền.");
				txtDonViNhanTien.Focus();
				showEP = true;
				return;
			}
            
            //Khong cho chi nhung chi phi bat buoc phai co PHIEU YEU CAU (dinh ngia trong Table: sys_ApplicationProperties)
            //TienMat.PhieuChi.ChiPhiPhaiCoPhieuYeuCau
            if ( txtSoPhieuYeuCau.Text =="" && GlobalVariable.WSInfo["TienMat.PhieuChi.ChiPhiPhaiCoPhieuYeuCau", ""].IndexOf(cboLyDoChi.SelectedValue.ToString()) >=1 )
            { 
                ep.SetError(txtSoPhieuYeuCau, "Thông cảm, khoản chi này phải có phiếu yêu cầu!");
                txtSoPhieuYeuCau.Focus();
                showEP = true;
                return;
            }

            ep.Clear();

			// dont regard to this code
			try {
				dgridChiTietPC.CurrentCell = 
					new DataGridCell(dgridChiTietPC.CurrentCell.RowNumber +1, 
					dgridChiTietPC.CurrentCell.ColumnNumber);
			} catch {}

			cancelHandlers = true;
			bmb.EndCurrentEdit();
			if (pc.update()) {
				setEditMode(false);
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
			sendStatus("Chứng từ đã được lưu thành công.");
		}

		private void cmdCancel_Click(object sender, System.EventArgs e) {
			bmb.EndCurrentEdit();

			DialogResult dr = DialogResult.Yes;
			if (pc.getTable(TienMatPhieuChiData.TL.TienMatPC).GetChanges() != null && 
				pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).GetChanges() != null) {
				dr = MessageBox.Show(this, RS.CANCEL_UPDATE, RS.CANCEL_UPDATE_CAPTION, 
					MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
			}
			
			if (dr == DialogResult.Yes) {
				cancelHandlers = true;
				pc.getDataSet().RejectChanges();
				cancelHandlers = false;
				setEditMode(false);
				bmb_PositionChanged(bmb, e);
			}
			chkNhapTTT_CheckedChanged(chkNhapTTT, e);
		}

		FormView fv = null;
		private void cmdView_Click(object sender, System.EventArgs e) {
			if (fv == null) {
				fv = new FormView("Select * from TienMat WHERE MaLoaiChungTu='" +
					GlobalVariable.WSInfo["TienMat.PhieuChi.MaLoaiCT"] +"'", GlobalVariable.WSInfo.ConnectionString,
                    GlobalVariable.WSInfo.WorkingDate );
				fv.DateFilterColumns = new string[,] {{"NgayChungTu", "Ngày chứng từ"}, {"UpdateDate", "Ngày cập nhật"}};
				
			}
			fv.ShowDialog(this);
			if (fv.DialogResult == DialogResult.OK) {
				cancelHandlers = true;
				pc.initData(fv.SelectedIDs, false);
				setEditMode(false);
				cancelHandlers = false;
				bmb_PositionChanged(bmb, e);
			}

		}

		private void cmdModify_Click(object sender, System.EventArgs e) {
			if (bmb.Position >= 0) {
				bmb.EndCurrentEdit();
				setEditMode(true);
				if (pc.getTable(TienMatPhieuChiData.TL.TienMatPC).Rows[bmb.Position].GetChildRows("M_D").Length > 1) {
                    //
                    dgridChiTietPC.Visible = false;
                    this.Size = this.MinimumSize;
                    cmdXemTK_Click(cmdXemTK, e);
                    //Disable nhung textbox ko the sua neu co nhieu dong o chi tiet
                    txtSoTien.Enabled = false;
                    cboLyDoChi.Enabled = false; 
				}
			}
		}

		private void cmdDelete_Click(object sender, System.EventArgs e) {
			DialogResult dr = MessageBox.Show(this, RS.DELETE_RECORD, RS.DELETE_RECORD_CAPTION, 
				MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
			if (dr == DialogResult.Yes) {
				cancelHandlers = true;
				bmb.RemoveAt(bmb.Position);
				pc.update();
				cancelHandlers = false;
				bmb_PositionChanged(bmb, e);
			}
		}

		private void cmdPrint_Click(object sender, System.EventArgs e) {

            //Load report
            ReportDocument rpt = new ReportDocument();
            rpt.Load(Application.StartupPath + "\\Report\\rpt_TienMat_PhieuChi.rpt");

            //Set connection
            PublicFunction.SetDBLogonForReport(rpt);

            //Set parameter
            PublicFunction.SetParameter(rpt, "@Sochungtu", txtSoChungTu.Text);
            PublicFunction.SetParameter(rpt, "pBangchu", ReportUtilities.ReportUtilities.g_Trans_VietNam(Double.Parse(txtSoTien.Text), "đồng", true));
            PublicFunction.SetParameter(rpt, "pNguoilapbieu", GlobalVariable.WSInfo.UserName);
            PublicFunction.SetParameter(rpt, "pThuquy", GlobalVariable.WSInfo["Sys.UserName.Thuquy"]);
            PublicFunction.SetParameter(rpt, "pKetoantruong", GlobalVariable.WSInfo["Sys.UserName.KetoanTruong"]);
            PublicFunction.SetParameter(rpt, "pGiamDoc", GlobalVariable.WSInfo["Sys.UserName.Giamdoc"]);

            //View report
            frmPrintPreview frmPP = new frmPrintPreview(rpt);
            frmPP.ShowDialog();
            frmPP.Dispose();

            rpt.Dispose();
		}

		#endregion

		private void cmdXemTK_Click(object sender, System.EventArgs e) {
            if (!cmdAddNew.Enabled && cboLyDoChi.SelectedIndex == -1) {
				ep.SetError(cboLyDoChi, "Bạn vui lòng chọn lý do thu !.");
				cboLyDoChi.Focus();
				showEP = true;
				return;
			}
			if (!cmdAddNew.Enabled && txtSoTien.Text.Trim() == "0") {
				ep.SetError(txtSoTien, "Bạn vui lòng nhập số tiền !.");
				txtSoTien.Focus();
				showEP = true;
				return;
			}
			if (!cmdAddNew.Enabled && txtDonViNhanTien.Text == "") {
				ep.SetError(txtDonViNhanTien, "Bạn vui lòng chọn đơn vị nộp tiền !.");
				txtDonViNhanTien.Focus();
				showEP = true;
				return;
			}

			dgridChiTietPC.Visible = !dgridChiTietPC.Visible;
			if (dgridChiTietPC.Visible) {
				this.Height += 120;
			} else {
				this.Size = this.MinimumSize;
				this.WindowState = FormWindowState.Normal;
			}
		}

		public int getNumOfDetailRows() {
			return pc.getTable(TienMatPhieuChiData.TL.TienMatPC).Rows[bmb.Position].GetChildRows("M_D").Length;
		}

		private void cboLyDoThu_SelectedIndexChanged(object sender, System.EventArgs e) {

            if (cancelHandlers || cboLyDoChi.SelectedIndex == -1) return;

            ep.Clear();

            //Kiem tra khoan chi co yeu cau Phieu yeu cau hay ko?
            if (GlobalVariable.WSInfo["TienMat.PhieuChi.ChiPhiPhaiCoPhieuYeuCau", ""].IndexOf(cboLyDoChi.SelectedValue.ToString()) >= 1)
            {
                txtSoPhieuYeuCau.TabStop = true;
                chkTTHet.TabStop = true;
                chkTTHet.Checked = true;
            }
            else
            {
                txtSoPhieuYeuCau.Text = "";
                txtSoPhieuYeuCau.TabStop = false;
                chkTTHet.TabStop = false;
                chkTTHet.Checked = false;
            }

			if (showEP) {
				ep.SetError(cboLyDoChi, null);
			}

			cancelHandlers = true;

			if (getNumOfDetailRows() > 0) {
				if (getNumOfDetailRows() > 1) { 
					if (MessageBox.Show(this, "Nếu bạn thay đổi lý do thu chúng tôi sẽ xóa toàn bộ dữ liệu trong lưới, tiếp tục ?",
						"Delete Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {

						DataRow[] drs = pc.getTable(TienMatPhieuChiData.TL.TienMatPC).Rows[bmb.Position].GetChildRows("M_D");
						for (int index = 0; index < drs.Length; index++) {
							drs[index].Delete();
						}
					} else {
						cboLyDoChi.SelectedIndex = (int)cboLyDoChi.Tag;
					}
				} else {
					DataRow[] drs = pc.getTable(TienMatPhieuChiData.TL.TienMatPC).Rows[bmb.Position].GetChildRows("M_D");
					for (int index = 0; index < drs.Length; index++) {
						drs[index].Delete();
					}
				}
			}

			// Gán tài khoản có mặc định cho detail
			pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).Columns["TaiKhoanNo"].DefaultValue = cboLyDoChi.SelectedValue;
 
			txtDienGiai.Text = ((string)txtDienGiai.Tag).Replace("<LyDoThu>", cboLyDoChi.Text).Replace("<TenDonVi>", lblTenDonViNhanTien.Text);

			cboLyDoChi.Tag = cboLyDoChi.SelectedIndex;
			//txtSoTien.Focus();
            
            txtSoTien_Validated(txtSoTien, e);

			buildDgridTS();

			cancelHandlers = false;
			
			if (chkNhapTTT.Checked) {
				chkNhapTTT.Checked = false;
			}
		}

		bool showEP = false;
		private void txtSoTien_Validated(object sender, System.EventArgs e) {
			//cancelHandlers = true; //Khong set de tu dong raise len event column changed
			if (txtSoTien.Text.Trim() != string.Empty && 
				txtSoTien.Text.Trim() != "0" && cboLyDoChi.SelectedIndex != -1) {

				if (pc.getTable(TienMatPhieuChiData.TL.TienMatPC).Rows[bmb.Position].GetChildRows("M_D").Length == 0) {
					// Add a default row to detail
					DataRow dr = pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).NewRow();
					dr["SoChungTu"] = txtSoChungTu.Text;
                    dr["MaTieuKhoanNo1"] = txtDonViNhanTien.Text;
					dr["SoTien"] = Double.Parse(txtSoTien.Text);
					dr["DienGiaiChiTiet"] = txtDienGiai.Text;
					pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).Rows.Add(dr);
				} else if (pc.getTable(TienMatPhieuChiData.TL.TienMatPC).Rows[bmb.Position].GetChildRows("M_D").Length == 1) {
                    pc.getTable(TienMatPhieuChiData.TL.TienMatPC).Rows[bmb.Position].GetChildRows("M_D")[0]["SoTien"] =
						Double.Parse(txtSoTien.Text);
                    //MessageBox.Show("Vao day");  
                }
			}
			bmb.EndCurrentEdit();
		}

		private void txtSoTien_TextChanged(object sender, System.EventArgs e) {
			if (showEP) {
				ep.SetError(txtSoTien, null);
			}
		}

		private void TienMatPhieuThu_Click(object sender, System.EventArgs e) {
			cancelHandlers = false;
		}

		private object this[string colName] {
			get { return pc.getTable(TienMatPhieuChiData.TL.TienMatPC).Rows[bmb.Position][colName]; }
			set { pc.getTable(TienMatPhieuChiData.TL.TienMatPC).Rows[bmb.Position][colName] = value; }
		}

		
		FormView lookupDVNT;
		private void cmdLookupDVNhanTiep_Click(object sender, System.EventArgs e) 
        {
            string strSELE = "";
            if (optBaoGomCaHocSinh.Checked)
                strSELE = "Select * from view_DoiTacBaoGomHocSinh where MaNienHoc = '" +  GlobalVariable.WSInfo.getAppProperty("MaNienHocDefault")  + "' or MaNienHoc = '' ";
            else
                strSELE = "Select * from DM_DoiTac";

			//if (lookupDVNT == null) lookupDVNT = new FormView(strSELE, GlobalVariable.WSInfo.ConnectionString);
            lookupDVNT = new FormView(strSELE, GlobalVariable.WSInfo.ConnectionString);
			lookupDVNT.SelectionMode = SelectionMode.One;
			lookupDVNT.addCreateNewAbility("Danh mục Đối tác", GlobalVariable.WSInfo.UserID);
			lookupDVNT.ShowDialog(this);
			if (lookupDVNT.DialogResult == DialogResult.OK) {
				txtDonViNhanTien.Text = lookupDVNT.SelectedIDs.Replace("('", "").Replace("')","");
				bmb.EndCurrentEdit();
			}
            txtDonViNhanTien.Focus();  //De run event Validate
            //txtDonViNhanTien_Validated(txtDonViNhanTien, e);
		}

		private void TienMatPhieuThu_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) {
			if (e.KeyCode == Keys.Enter) {
				this.SelectNextControl(this.ActiveControl, true, true, true, true);
			} else if (e.KeyCode == Keys.Escape) {
				this.SelectNextControl(this.ActiveControl, true, false, true, true);
			}
		}

		private void cmdMoveFirst_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (bmb != null && bmb.Count > 0) {
				bmb.Position = 0;
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void cmdMovePrevious_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (bmb != null && bmb.Position > 0) {
				bmb.Position -= 1;
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void cmdMoveLast_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (bmb != null && bmb.Count > 0) {
				bmb.Position = bmb.Count -1;
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void cmdMoveNext_Click(object sender, System.EventArgs e) {
			cancelHandlers = true;
			if (bmb != null && bmb.Position < bmb.Count -1) {
				bmb.Position += 1;
			}
			cancelHandlers = false;
			bmb_PositionChanged(bmb, e);
		}

		private void sendStatus(string msg) {
			sendStatus(msg, false);
		}

		private void pictureBox2_Click(object sender, System.EventArgs e)
		{
		
		}

		private void txtAddCoThueToDetail_Validated(object sender, System.EventArgs e) {
			addCoThueToDetail();
		}

		private void txtThueSuat_Validated(object sender, System.EventArgs e) {
			if (txtThueSuat.Text.Trim() == string.Empty) {
				txtThueSuat.Text = "0";
			}
			try {
				double num = double.Parse(txtThueSuat.Text);
			} catch {
				txtThueSuat.Text = "0";
				txtThueSuat.Focus();
				sendStatus("Bạn vui lòng nhập thuế suất chính xác.", true);
			}
			addCoThueToDetail();
		}

		private void chkNhapTTT_CheckedChanged(object sender, System.EventArgs e) {
			if (cancelHandlers) return;
			if (bmb.Position < 0) {
				return;
			}
			cancelHandlers = true;
			
          	pnlTTT.Visible = chkNhapTTT.Checked;
			txtThueSuat.Visible = chkNhapTTT.Checked;
			lblThueSuat.Visible = chkNhapTTT.Checked;
            

			cancelHandlers = false;
			bmb.EndCurrentEdit();
            txtThueSuat.Focus();
		}

	
		private void addCoThueToDetail() {
			if (cmdAddNew.Enabled) return;

			if (!(getNumOfDetailRows() > 0)) {
				txtSoTien_Validated(txtSoTien, null);

				if (!(getNumOfDetailRows() > 0)) {
					sendStatus("Lỗi, không tìm thấy chi tiết.", true);
					return;
				}
			}

			if (getNumOfDetailRows() > 1) {
				sendStatus("Bạn vui lòng nhập tại chi tiết.", true);
				return;
			}

            //Them 1 dong hach toan thue GTGT
            //cancelHandlers = true; //Khong set de tu dong raise len event column changed
            if (txtThueSuat.Text.Trim() != string.Empty &&
                txtThueSuat.Text.Trim() != "0" && cboLyDoChi.SelectedIndex != -1)
            {
                // Add a default row to detail
                DataRow dr = pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).NewRow();
                dr["SoChungTu"] = txtSoChungTu.Text;
                dr["TaiKhoanNo"] = "1331";
                dr["MaTieuKhoanNo1"] = txtDonViNhanTien.Text;
                dr["SoTien"] = Double.Parse(txtThueSuat.Text) * Double.Parse(txtSoTien.Text) /100 ;
                dr["DienGiaiChiTiet"] = "Thuế GTGT - " + txtDienGiai.Text;
                pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).Rows.Add(dr);
            }
            bmb.EndCurrentEdit();
            double dblTemp  = (double)(decimal)pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).Compute("Sum(SoTien)", "SoChungTu='" + this["SoChungTu"] + "'");
            txtSoTien.Text = dblTemp.ToString();
		}

		private void picboxHelp_Click(object sender, System.EventArgs e) {
		
		}

		private void cmdNote_Click(object sender, System.EventArgs e) {
			SimpleObjectNote son = new SimpleObjectNote(GlobalVariable.WSInfo.ConnectionString,
				this.Text, GlobalVariable.WSInfo.UserID);
			son.ShowDialog(this);
		}
	
		private void sendStatus(string msg, bool error) {
			if (error) {
				lblStatus.ForeColor = Color.Red;
				lblStatus.Text = msg;
			} else {
				lblStatus.ForeColor = Color.Black;
				lblStatus.Text = msg;
			}
		}

        private void txtSoTien_TextChanged_1(object sender, EventArgs e)
        {

        }

        private void TienMatPhieuChi_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
            }
            else if (e.KeyCode == Keys.Escape)
            {
                this.SelectNextControl(this.ActiveControl, true, false, true, true);
            }
        }

        private void txtDienGiai_Validated(object sender, EventArgs e)
        {
            try
            {
                pc.getTable(TienMatPhieuChiData.TL.TienMatPC).Rows[bmb.Position].GetChildRows("M_D")[0]["DienGiaiChiTiet"] = txtDienGiai.Text;
                cmdUpdate.Focus();
            }
            catch { }
        }

      
        private void txtDonViNhanTien_KeyDown(object sender, KeyEventArgs e)
        {
            if ((txtDonViNhanTien.Text == "" && e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.F3))
            {
                cmdLookupDVNhanTiep_Click(cmdLookupDVNhanTiep, e);
            }
        }

        private void txtDonViNhanTien_Validated(object sender, EventArgs e)
        {
            if (txtDonViNhanTien.Text == "") return;

            //Khong co trong danh muc doi tac cung ko duoc
            try
            {
                //Neu ko co se xuong catch
                string str = CNCSoft.EData.SQLHelper.ExecuteScalar(GlobalVariable.WSInfo.ConnectionString,
                            "SELECT MaDoiTac FROM view_DoiTacBaoGomHocSinh WHERE MaDoiTac = '" + txtDonViNhanTien.Text + "'").ToString();
                //MessageBox.Show(this, "Đối tác này không có", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch {
                //txtDonViNhanTien.Focus(); 
                txtDonViNhanTien.Text = "";
                return;
            }
            

            try
            {
                lblTenDonViNhanTien.Text = SQLHelper.ExecuteScalar(GlobalVariable.WSInfo.ConnectionString, "SELECT TenDoiTac FROM view_DoiTacBaoGomHocSinh WHERE MaDoiTac= '" + txtDonViNhanTien.Text + "'").ToString();
                txtHoTenNguoiNhanTien.Text = SQLHelper.ExecuteScalar(GlobalVariable.WSInfo.ConnectionString, "SELECT NguoiDaiDien FROM view_DoiTacBaoGomHocSinh WHERE MaDoiTac= '" + txtDonViNhanTien.Text + "'").ToString();
                txtDiaChi.Text = SQLHelper.ExecuteScalar(GlobalVariable.WSInfo.ConnectionString, "SELECT DiaChi FROM view_DoiTacBaoGomHocSinh WHERE MaDoiTac= '" + txtDonViNhanTien.Text + "'").ToString();
                txtMaSoThue.Text = SQLHelper.ExecuteScalar(GlobalVariable.WSInfo.ConnectionString, "SELECT MaSoThue FROM view_DoiTacBaoGomHocSinh WHERE MaDoiTac= '" + txtDonViNhanTien.Text + "'").ToString();

            }
            catch{ }
            
            txtDienGiai.Text = ((string)txtDienGiai.Tag).Replace("<LyDoThu>", cboLyDoChi.Text).Replace("<TenDonVi>", lblTenDonViNhanTien.Text);
            bmb.EndCurrentEdit();
        }

        private void dgridChiTietPC_Validated(object sender, EventArgs e)
        {
            txtSoTien.Text = ((double)(decimal)pc.getTable(TienMatPhieuChiData.TL.TienMatPC_CT).Compute("Sum(SoTien)", "SoChungTu='" + this["SoChungTu"] + "'")).ToString("N");
        }

        private void txtDonViNhanTien_TextChanged(object sender, EventArgs e)
        {

        }

        
      /*
        FormView lookupPYC;
        private void cmdLookupSoPhieuYeuCau_Click(object sender, EventArgs e)
        {
            //if (lookupPYC == null) 
                lookupPYC = new FormView("SELECT * FROM BIEUMAU_PHIEUYEUCAU " +
                                                            "WHERE NguoiDuyet != '' AND SoPYC not IN (SELECT SoPhieuYeuCau FROM TIENMAT WHERE ThanhToanHetPYC = 1)", 
                                                   GlobalVariable.WSInfo.ConnectionString);
            lookupPYC.SelectionMode = SelectionMode.One;
            lookupPYC.addCreateNewAbility("Phiếu yêu cầu", GlobalVariable.WSInfo.UserID);
            lookupPYC.ShowDialog(this);
            if (lookupPYC.DialogResult == DialogResult.OK)
            {
                txtSoPhieuYeuCau.Text = lookupPYC.SelectedIDs.Replace("('", "").Replace("')", "");
                bmb.EndCurrentEdit();
            }
            txtSoPhieuYeuCau.Focus();  //De run event Validate
        }

        */
       
     

       
	}
}
